#include <bits/stdc++.h>

using namespace std;
#define int long long
const int inf = 0x3f3f3f3f;

int holes_cnt[26] = { 1, 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 };

void solve()
{
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < 26; i++)
	{
		int sum = 0;
		for (int j = 0; j < s.size(); j++) sum += holes_cnt[(char)((s[j] - 'A' + i) % 26 + 'A') - 'A'];
		//cout << sum << endl;
		ans = max(ans, sum);
	}
	cout << ans << endl;
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int _ = 1;
	//cin >> _;
	while (_--)
	{
		solve();
	}
	return 0;
}